/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaPrincipal.java
 *
 * Created on 17/04/2011, 04:45:01 PM
 */

package GUI;

import Datos.PersonaNatural;
import Lógica.*;

/**
 *
 * @author Rodrigo Uzcátegui
 */
public class VentanaPrincipal extends javax.swing.JFrame
{

    private String Nickname, Password = "";
    private PersonaNatural Usuario = null;

    /** Creates new form VentanaPrincipal */
    public VentanaPrincipal()
    {
        initComponents();
        inicializaMisComponentes();
    }

    private void inicializaMisComponentes()
    {
        ComponentesGUIFrame.modificarTazaDeJavaYNombreVentana(this,"Supermercado Vila Lais - Iniciar Sesión");
        ComponentesGUIFrame.componentesBásicos(this, true, false);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTFNickname = new org.edisoncor.gui.textField.TextFieldRoundIcon();
        jPFPassword = new org.edisoncor.gui.passwordField.PasswordFieldRoundIcon();
        jBEntrar = new org.edisoncor.gui.button.ButtonAction();
        jLNickname = new javax.swing.JLabel();
        jLPassword = new javax.swing.JLabel();
        jBSalir = new org.edisoncor.gui.button.ButtonAction();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTFNickname.setFont(new java.awt.Font("Tahoma", 1, 11));

        jPFPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPFPasswordActionPerformed(evt);
            }
        });

        jBEntrar.setText("Entrar");
        jBEntrar.setFont(new java.awt.Font("Tahoma", 1, 11));
        jBEntrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBEntrarActionPerformed(evt);
            }
        });

        jLNickname.setFont(new java.awt.Font("Arial Rounded MT Bold", 1, 11));
        jLNickname.setForeground(new java.awt.Color(0, 0, 102));
        jLNickname.setText("Nombre de Usuario:");

        jLPassword.setFont(new java.awt.Font("Arial Rounded MT Bold", 1, 11));
        jLPassword.setForeground(new java.awt.Color(0, 0, 102));
        jLPassword.setText("Contraseña:");

        jBSalir.setText("Salir");
        jBSalir.setFont(new java.awt.Font("Tahoma", 1, 11));
        jBSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSalirActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Herramientas/Logo Supermercado1.gif"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(244, 244, 244)
                .addComponent(jTFNickname, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(147, 147, 147)
                .addComponent(jLPassword)
                .addGap(18, 18, 18)
                .addComponent(jPFPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(155, 155, 155)
                .addComponent(jBEntrar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(jLNickname))
            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 399, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jTFNickname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLPassword))
                    .addComponent(jPFPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBEntrar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLNickname))
            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jPFPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPFPasswordActionPerformed
        jBEntrarActionPerformed(evt);
}//GEN-LAST:event_jPFPasswordActionPerformed

    private void jBEntrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBEntrarActionPerformed
        setNickname(jTFNickname.getText());
        setPassword(jPFPassword.getText());
        if (ComponentesGUIValidadores.validarUsuario(Nickname, Password))
        {
            MenúGerenteGeneral menúGerente = new MenúGerenteGeneral();
            menúGerente.setVentanaPadre(this);
            ComponentesGUIFrame.habilitarVentana(this, false, false);
            ComponentesGUIFrame.habilitarVentana(menúGerente, true, true);
        }
        else
        {
            MenúEmpleado menúEmpleado = new MenúEmpleado();
            menúEmpleado.setVentanaPadre(this);
            ComponentesGUIFrame.habilitarVentana(this, false, false);
            ComponentesGUIFrame.habilitarVentana(menúEmpleado, true, true);
        }
}//GEN-LAST:event_jBEntrarActionPerformed

    private void jBSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSalirActionPerformed
        System.exit(0);
}//GEN-LAST:event_jBSalirActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaPrincipal().setVisible(true);
            }
        });
    }

//    public String getNickname() {
//        return Nickname;
//    }
//
    public void setNickname(String Nickname) {
        this.Nickname = Nickname;
    }
//
//    public String getPassword() {
//        return Password;
//    }
//
    public void setPassword(String Password) {
        this.Password = Password;
    }
//
//    public PersonaNatural getUsuario() {
//        return Usuario;
//    }
//
//    public void setUsuario(PersonaNatural Usuario) {
//        this.Usuario = Usuario;
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonAction jBEntrar;
    private org.edisoncor.gui.button.ButtonAction jBSalir;
    private javax.swing.JLabel jLNickname;
    private javax.swing.JLabel jLPassword;
    private javax.swing.JLabel jLabel1;
    private org.edisoncor.gui.passwordField.PasswordFieldRoundIcon jPFPassword;
    private org.edisoncor.gui.textField.TextFieldRoundIcon jTFNickname;
    // End of variables declaration//GEN-END:variables

}
